FROM ubuntu:24.04
MAINTAINER Tommy<li_zongjin@qq.com>

#添加源
RUN cat >> /etc/apt/sources.list.d/ubuntu.sources <<EOF  
Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
EOF

RUN	apt update && echo 'Asia/Shanghai' > /etc/timezone

#安装系统工具
RUN apt install -y tzdata gcc  

#设置时区：中国时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && apt clean

#安装Python3.10
COPY assets/Miniconda3-py310_24.3.0-0-Linux-x86_64.sh /
RUN sh /Miniconda3-py310_24.3.0-0-Linux-x86_64.sh -b -p /opt/miniconda && rm -f /Miniconda3-py310_24.3.0-0-Linux-x86_64.sh

#设置环境变量
ENV PATH="/opt/miniconda/bin:$PATH"

#设置pip源
RUN pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/

#安装PaddlePaddle
RUN pip install paddlepaddle==2.6.1 -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html

#安装PaddleTS
COPY assets/PaddleTS /opt/PaddleTS
RUN cd /opt/PaddleTS && pip install -r requirements.txt && python setup.py install && rm -fr /opt/PaddleTS

#安装web服务
RUN pip install fastapi==0.112.2 uvicorn==0.30.6 && pip cache purge

#拷贝脚本 & 添加执行权限
COPY assets/ppts_serving.py /
COPY assets/docker-entrypoint.sh /

RUN chmod 755 /docker-entrypoint.sh

#开放端口（仅在随机端口时，自动映射）
EXPOSE 8000

#创建模型目录
RUN mkdir /models

#设置工作目录
WORKDIR /

#启动容器时，执行的命令
CMD ["/docker-entrypoint.sh"]
